#!/usr/bin/perl 
use DBI;
use CGI;
use TTraker;

print_header();
initialize_dbi();


my $form_ref = parse_input();

my %FORM_DATA = %$form_ref; 

my $num = $FORM_DATA{'num'};
my $name = $FORM_DATA{'name'};
my $job = $FORM_DATA{'job'};
my $loc = $FORM_DATA{'loc'};
my $dir = $FORM_DATA{'dir'};
my $cli = $FORM_DATA{'client'};

my $log_status = 0;
my $now = get_local_time($loc);

# check for log in time being excessive
$log_status_ref = log_in_get_status ($num, $now); # returns an array of time info regarding the current log in
($log_elapsed, $job_elapsed, $log_start, $job_start, $log_hrs, $job_hrs, $dow, $month, $day, $year, $time, $nod, $date) = @$log_status_ref;
$noh = sprintf "%.1f", $log_elapsed/60;
if ($log_elapsed > 600 && $job_elapsed > 300 || $log_elapsed > 600 && $job_elapsed eq "" ) {
	$log_status = 1;
}

if ( $log_status == 1 ) {
	log_in_screen_from_pm ();
} else { 
	my $session = get_new_count(SESSION);
	make_client_active ($cli);
	create_new_job ($num,"",$cli,$session,$dir,$loc);
	clear_hold_jobs($num);
	csr_work_screen_from_pm ($num, $name, $job, $loc, "NONE");
}

##################### SUBROUTINES FOLLOW  #####################


